package com.dgut.dao;

import com.dgut.domain.Customer;
import org.apache.ibatis.jdbc.SQL;

public class CustomerDynaSQL {
    public String selectCustomer(Customer customer){
        return new SQL(){
            {
                SELECT("*");
                FROM("customer");
                if(customer.getName() != ""){
                    WHERE("name like #{name}");
                }
                if(customer.getIndustry() != ""){
                    WHERE("industry = #{industry}");
                }
                if(customer.getLevel() != ""){
                    WHERE("level = #{level}");
                }

            }
        }.toString();
    }
}
